﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Xml.Linq;
using System.Text;

namespace MediawikiSPMigratorClass
{
    public class MappingData
    {
        public MappingData()
        {

        }

        public XElement GetMappingDetails(string TemplateName)
        {
            string mappingFile = ConfigurationManager.AppSettings["MappingFile"];
            XDocument mapping = XDocument.Load(mappingFile);
            var result = from t in mapping.Descendants("Template")
                         where ((XElement)t).Attribute("Type").Value == TemplateName
                         select t;

            if (result.Count() > 0)
            {
                return result.First();
            }
            throw new Exception("Unable to find template " + TemplateName + " from Mapping file");
        }
    }
}
